package com.my.designPattern_old;

/**
 *  单例模式二之: 单线程写法
 *  缺点：线程不安全，当两个线程同时访问创建单例方法getSingleton2()，有可能创建2个新对象
 */
public class Singleton2 {

    private static Singleton2 singleton2 = null;

    private Singleton2(){

    }

    public static Singleton2 getSingleton2(){
        if(singleton2 == null){
            return new Singleton2();
        }
        return singleton2;
    }

}
